﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 晨曦超市管理系统.会员信息
{
    public partial class MemberInformation : Form
    {
        public MemberInformation()
        {
            InitializeComponent();
        }

        private void MemberInformation_Load(object sender, EventArgs e)
        {
            comboBox2.Items.Add("男");
            comboBox2.Items.Add("女");
            comboBox1.Items.Add("黄金");
            comboBox1.Items.Add("钻石");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string memberName = textBox1.Text.Trim();
                string Mobile = textBox2.Text.Trim();
                string Integral = textBox3.Text.Trim();
                string Balance = textBox4.Text.Trim();
                string xiaofei = textBox5.Text.Trim();
                string MemberPaw = textBox6.Text.Trim();
                string sex = comboBox2.Text;
                string Discount = textBox12.Text.Trim();
                string lianxidinghua = textBox8.Text.Trim();
                string lianxidizhi = textBox9.Text.Trim();
                string Grade = comboBox1.Text;
                string CardID = textBox10.Text.Trim();
                string Remark = textBox11.Text.Trim();
                string sqlstr = string.Format("insert into Menber(memberName,Mobile,Integral,Balance,xiaofei,MemberPaw,sex,Discount,lianxidinghua,lianxidizhi,CardID,Remark,Grade) values('{0}','{1}',{2},{3},{4},'{5}','{6}',{7},'{8}','{9}','{10}','{11}','{12}')", memberName, Mobile, Integral, Balance, xiaofei, MemberPaw, sex, Discount, lianxidinghua, lianxidizhi, CardID, Remark, Grade);
                bool A = DBHelper.QEX(sqlstr);
                if (A)
                {
                    MessageBox.Show("添加成功");
                    if (checkBox3.Checked)
                    {
                        textBox1.Text = "";
                        textBox2.Text = "";
                        textBox3.Text = "";
                        textBox4.Text = "";
                        textBox5.Text = "";
                        textBox6.Text = "";
                        textBox12.Text = "";
                        textBox8.Text = "";
                        textBox9.Text = "";
                        textBox10.Text = "";
                        textBox11.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {
            if (textBox6.Text.Trim() == textBox7.Text.Trim())
            {
                label13.Text = "正确";
            }
            else
            {
                label13.Text = "密码不一致";
            }
        }
    }
}
